var myCirclePlayer;
var currItemNumber;
var sermonList = [
	"../AUDIO/2001-2007/HEBREWS/02-11-07%20AM%20VAN%20DYKE%20HEBREWS%20INTRO.mp3",
	"../AUDIO/2001-2007/HEBREWS/02-11-07%20PM%20VAN%20DYKE%20HEBREW%20INTRO%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/02-18-07%20AM%20VAN%20DYKE%20HEBREWS%201%3b1-3.mp3",
	"../AUDIO/2001-2007/HEBREWS/02-18-07%20PM%20VAN%20DYKE%20HEBREWS%201%3b1-3.mp3",
	"../AUDIO/2001-2007/HEBREWS/02-25-07%20AM%20VAN%20DYKE%20HEBREWS%201.mp3",
	"../AUDIO/2001-2007/HEBREWS/03-04-07%20AM%20VAN%20DYKE%20%20HEBREWS%201.mp3",
	"../AUDIO/2001-2007/HEBREWS/03-04-07%20PM%20VAN%20DYKE%20%20HEBREWS%201.mp3",
	"../AUDIO/2001-2007/HEBREWS/03-11-07%20AM%20VAN%20DYKE%20%20HEBREWS%201%3b1-14.mp3",
	"../AUDIO/2001-2007/HEBREWS/03-11-07%20PM%20VAN%20DYKE%20%20HEBREWS%201%3b1-14.mp3",
	"../AUDIO/2001-2007/HEBREWS/03-18-07%20AM%20VAN%20DYKE%20%20HEBREWS%201%3b1-14.mp3",
	"../AUDIO/2001-2007/HEBREWS/03-18-07%20PM%20VAN%20DYKE%20%20HEBREWS%201%3b1-14.mp3",
	"../AUDIO/2001-2007/HEBREWS/03-25-07%20AM%20VAN%20DYKE%20%20HEBREWS%202%3b1-4.mp3",
	"../AUDIO/2001-2007/HEBREWS/04-08-07%20AM%20VAN%20DYKE%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/04-08-07%20PM%20VAN%20DYKE%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/04-15-07%20AM%20VAN%20DYKE%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/04-15-07%20PM%20VAN%20DYKE%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/04-22-07%20AM%20VAN%20DYKE%20%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/04-22-07%20PM%20VAN%20DYKE%20%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/04-29-07%20AM%20VAN%20DYKE%20%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/05.06.07%20AM%20VAN%20DYKE%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/05.13.07%20AM%20VAN%20DYKE%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/05.20.07%20AM%20VAN%20DYKE%20%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/05.20.07%20PM%20VAN%20DYKE%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/05.27.07%20AM%20VAN%20DYKE%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/05.27.07%20PM%20VAN%20DYKE%20HEBREWS%202.mp3",
	"../AUDIO/2001-2007/HEBREWS/06.03.07%20AM%20VAN%20DYKE%20HEBREWS%203.mp3",
	"../AUDIO/2001-2007/HEBREWS/06.10.07%20AM%20VAN%20DYKE%20HEBREWS%203.mp3",
	"../AUDIO/2001-2007/HEBREWS/06.10.07%20PM%20VAN%20DYKE%20HEBREWS%203.mp3",
	"../AUDIO/2001-2007/HEBREWS/06.17.07%20AM%20VAN%20DYKE%20%20HEBREWS%203.mp3",
	"../AUDIO/2001-2007/HEBREWS/06.17.07%20PM%20VAN%20DYKE%20HEBREWS%20%204.mp3",
	"../AUDIO/2001-2007/HEBREWS/06.24.07%20AM%20VAN%20DYKE%20HEBREWS%204.mp3",
	"../AUDIO/2001-2007/HEBREWS/07.01.07%20AM%20VAN%20DYKE%20%20HEBREWS%204.mp3",
	"../AUDIO/2001-2007/HEBREWS/07.01.07%20PM%20VAN%20DYKE%20%20HEBREWS%204.mp3",
	"../AUDIO/2001-2007/HEBREWS/07.08.07%20AM%20VAN%20DYKE%20%20HEBREWS%20%204%20%26%205.mp3",
	"../AUDIO/2001-2007/HEBREWS/07.08.07%20PM%20VAN%20DYKE%20HEBREWS%205.mp3",
	"../AUDIO/2001-2007/HEBREWS/07.15.07%20AM%20VAN%20DYKE%20HEBREWS%205.mp3",
	"../AUDIO/2001-2007/HEBREWS/07.15.07%20PM%20VAN%20DYKE%20HEBREWS%205.mp3",
	"../AUDIO/2001-2007/HEBREWS/08.12.07%20AM%20VAN%20DYKE%20%20HEBREWS%206.mp3",
	"../AUDIO/2001-2007/HEBREWS/08.12.07%20PM%20VAN%20DYKE%20HEBREWS%206.mp3",
	"../AUDIO/2001-2007/HEBREWS/08.19.07%20AM%20VAN%20DYKE%20%20HEBREWS%206.mp3",
	"../AUDIO/2001-2007/HEBREWS/08.19.07%20PM%20VAN%20DYKE%20%20HEBREWS%206.mp3",
	"../AUDIO/2001-2007/HEBREWS/08.25.07%20AM%20VAN%20DYKE%20%20HEBREWS%207.mp3",
	"../AUDIO/2001-2007/HEBREWS/09.02.07%20AM%20VAN%20DYKE%20HEBREWS%207.mp3",
	"../AUDIO/2001-2007/HEBREWS/09.09.07%20AM%20VAN%20DYKE%20HEBREWS%207.mp3",
	"../AUDIO/2001-2007/HEBREWS/09.09.07%20PM%20VAN%20DYKE%20%20HEBREWS%207.mp3",
	"../AUDIO/2001-2007/HEBREWS/11.04.07%20AM%20VAN%20DYKE%20HEBREWS%209.mp3",
	"../AUDIO/2001-2007/HEBREWS/11.04.07%20PM%20VAN%20DYKE%20%20HEBREWS%209.mp3",
	"../AUDIO/2001-2007/HEBREWS/11.11.07%20AM%20VAN%20DYKE%20%20HEBREWS%2010.mp3",
	"../AUDIO/2001-2007/HEBREWS/11.11.07%20PM%20VAN%20DYKE%20HEBREWS%2010.mp3",
	"../AUDIO/2001-2007/HEBREWS/11.25.07%20AM%20VAN%20DYKE%20HEBREWS%2010.mp3",
	"../AUDIO/2001-2007/HEBREWS/12.02.07%20AM%20VAN%20DYKE%20%20HEBREWS%2010.mp3",
	"../AUDIO/2001-2007/HEBREWS/12.09.07%20AM%20VAN%20DYKE%20%20HEBREWS%2010%20%26%2011.mp3",
	"../AUDIO/2001-2007/HEBREWS/12.09.07%20PM%20VAN%20DYKE%20HEBREWS%2010.mp3",
	"../AUDIO/2001-2007/HEBREWS/12.30.07%20AM%20VAN%20DYKE%20%20HEBREWS%2010%20%26%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/01-06-08%20AM%20VAN%20DYKE%20%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/01-06-08%20PM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/01-27-08%20%20AM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/02-03-08%20AM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/02-10-08%20AM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/02-17-08%20AM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/02-24-08%20AM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/03-03-08%20AM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/03-03-08%20PM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/03-16-08%20AM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/03-30-08%20AM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/05-04-08%20AM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/05-04-08%20PM%20VAN%20DYKE%20HEBREWS%2011.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/05-18-08%20AM%20VAN%20DYKE%20HEBREWS%2012.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/05-18-08%20PM%20VAN%20DYKE%20HEBREWS%2012.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/05-25-08%20AM%20VAN%20DYKE%20HEBREWS%2012.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/06-08-08%20AM%20VAN%20DYKE%20HEBREWS%2012.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/06-22-08%20AM%20VAN%20DYKE%20HEBREWS%2012.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/06-29-08%20AM%20VAN%20DYKE%20HEBREWS%2012.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/07-06-08%20AM%20VAN%20DYKE%20HEBREWS%2012%20%26%20Galloway%20Singing.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/07-06-08%20PM%20VAN%20DYKE%20HEBREWS%2012.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/07-13-08%20AM%20VAN%20DYKE%20HEBREWS%2013.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/07-13-08%20PM%20VAN%20DYKE%20HEBREWS%2013.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/07-20-08%20AM%20VAN%20DYKE%20HEBREWS%2013.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/07-27-08%20AM%20VAN%20DYKE%20HEBREWS%2013.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/08-10-08%20AM%20VAN%20DYKE%20HEBREWS%2013.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/08-17-08%20AM%20VAN%20DYKE%20HEBREWS%2013.mp3",
	"../AUDIO/2008/VAN%20DYKE/HEBREWS/08-17-08%20PM%20VAN%20DYKE%20HEBREWS%20SUMMARY.mp3"
];

function selectItem(item) {
    if (0 <= currItemNumber && currItemNumber < sermonList.length) {
    	var currItem = document.getElementById("player-item-" + currItemNumber.toString());
        removeClass(currItem, 'bold');
        removeClass(currItem, 'colorPrimary-5');
        addClass(currItem, 'colorSecondary-a-2');
    }
    addClass(item, 'bold');
    addClass(item, 'colorPrimary-5');
    removeClass(item, 'colorSecondary-a-2');
    currItemNumber = parseInt(item.id.substr(item.id.lastIndexOf("-") + 1));
    myCirclePlayer.setMedia({
    	mp3: sermonList[currItemNumber]
    });
}

function playItem(item) {
    selectItem(item);
	myCirclePlayer.play();
}

function playNextItem() {
    var nextItemNumber = currItemNumber + 1;
    if (nextItemNumber < sermonList.length) {
        playItem(document.getElementById("player-item-" + nextItemNumber.toString()));
    }
}

$(document).ready(function(){
	myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
	{
	}, {
		supplied: "mp3",
		cssSelectorAncestor: "#cp_container_1",
		swfPath: "../Content/Javascript/jplayer/Jplayer.swf",
		wmode: "window",
		keyEnabled: true
	});

    $("#jquery_jplayer_1").bind($.jPlayer.event.ended, function (event) {
        playNextItem();
    });
    
    for(var i = 0; i < sermonList.length; ++i){
		addClass(document.getElementById("player-item-" + i.toString()), 'colorSecondary-a-2');
	}

    selectItem(document.getElementById("player-item-0"));
});
